<?php

/**
 * A color that can be used in the image
 *
 * @version $Revision v1.00$
 * @author Bryan Spirit & Mark Kazemier
 */
class Color
{
    private $m_iColor;

    /**
     * Constructs a new Color
     *
     * @throws ColorAllocationException When the color cannot be allocated
     * @param Image The image in which the color will be used
     * @param integer The red value of the color
     * @param integer The green value of the color
     * @param integer The blue value of the color
     */
    public function __construct(Image $oImage, $iRed, $iGreen, $iBlue)
    {
        $this->m_iColor = imagecolorallocate($oImage->getResource(), $iRed, $iGreen, $iBlue);
        
        if(!$this->m_iColor)
            throw new ColorAllocationException('The color could not be allocated');
    }
    
    
    /**
     * Method to get the color
     *
     * @return The color
     */
    public function getColor()
    {
        return $this->m_iColor;
    }
}
